package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/vue")
public class VueController {
@Autowired
    private UserService userService;
//@GetMapping("/findall")
//    public List<User>findall(){
//    return userService.findall();
//}
@GetMapping("/findall")
public List<User>findall(){
    return userService.findall();
}

//@DeleteMapping("/deleteuserById")
//public String deleteuserById(Integer id) {
//    userService.deleteuserById(id);
//    return "删除成功";
//}
@PostMapping("/saveuser")
    public String saveuser(@RequestBody User user){
    userService.saveuser(user);
    return "增加成功";
}
@GetMapping("/findALl")
    public List<User> findALl(){
    return userService.findALl();
}
@DeleteMapping("/deletebyId")
    public String deletebyId(Integer id){
    userService.deletebyId(id);
    return "删除成功";
}
@PostMapping("/Saveuser")
    public String Saveuser(@RequestBody User user){
    userService.Saveuser(user);
    return "增加成功";
}
//@GetMapping("/findAll")
//    public List<User>findAll(){
//    return userService.findAll();
//}
@DeleteMapping("/deleteuserBYid")
    public String deleteuserBYid(Integer id){
    userService.deleteuserBYid(id);
    return "删除成功";
}
//@PostMapping("/saveUSer")
//    public String saveUSer(@RequestBody User user){
//userService.saveUSer(user);
//return "增加成功";
//}
//@PutMapping("/updateuser")
//    public String updateuser(@RequestBody User user){
//    userService.updateuser(user);
//    return "修改成功";
//}
@PutMapping("/updateUser")
    public String updateUser(@RequestBody User user){
    userService.updateUser(user);
    return "修改成功";
}
@DeleteMapping("/deleteUserById")
    public String deleteUserById(Integer id){
    userService.deleteUserById(id);
    return "删除成功";
}
@PostMapping("/saveUser")
    public String saveUser(@RequestBody User user){
    userService.saveUser(user);
    return "增加成功";
}
@PutMapping("/updateuser")
    public String updateuser(@RequestBody User user){
    userService.updateuser(user);
    return "修改成功";
}
@GetMapping("/findAll")
    public List<User>findAll(){
    return userService.findAll();
}
@DeleteMapping("/deleteById")
    public String deleteById(Integer id){
    userService.deleteById(id);
    return "删除成功";
}
@PostMapping("/update")
    public String update(@RequestBody User user){
    userService.update(user);
    return "修改成功";
}
@PutMapping("/save")
    private String save(@RequestBody User user){
    userService.save(user);
    return "增加成功";
}









}
